#include <iostream>
#include <vector>

class Solution {
    int path;
    int sum;
public:
    int subsetXORSum(std::vector<int>& nums)
    {
        dfs(nums, 0);
        return sum;
    }

    void dfs(std::vector<int>& nums, int pos)
    {
        std::cout << "Current path: " << path << std::endl;
        sum += path;

        std::cout << "Current sum: " << sum << std::endl;
        for (int i = pos; i < nums.size(); i++)
        {
            path ^= nums[i];
            std::cout << "Adding " << nums[i] << " to path. New path: " << path << std::endl;
            dfs(nums, i + 1);
            path ^= nums[i];
            std::cout << "Removing " << nums[i] << " from path. New path: " << path << std::endl;
        }
    }
};

int main()
{
    Solution sol;
    std::vector<int> nums = { 1, 2, 3 };
    int result = sol.subsetXORSum(nums);
    std::cout << "Final result: " << result << std::endl;
    return 0;
}